<?php

namespace app\company\controller\report;

use app\common\controller\CompanyController;
use app\company\model\ReportDriverDelivery;
use think\App;
use think\response\Json;

class Driver extends CompanyController
{
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model = new ReportDriverDelivery();
    }

    public function list(): Json
    {
        $get = $this->request->get();
        $where = [];
        if(!empty($get['time'])){
            [$beginTime,$endTime] = json_decode($get['time'],true);
            $where[] = ['time', '>=', $beginTime];
            $where[] = ['time', '<=', $endTime];
        }
        $sql     = $this->model->where($this->defaultWhere);
        $list    = $sql->where($where)->order(['time' => 'desc', 'goods_value' => 'desc'])
                       ->paginate($get['limit']);
        return $this->success($list);
    }

}